package com.example.everying.service.user.impl;/*
 * 项目名称: everything
 * 文件名: UserLabelRelServiceImpl
 * 作者: 张泽阳
 * 日期: 2025/5/23
 * 描述:
 */

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.everying.mapper.user.UserLabelRelMapper;
import com.example.everying.model.entity.user.UserLabelRelEntity;
import com.example.everying.service.user.UserLabelRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserLabelRelServiceImpl extends ServiceImpl<UserLabelRelMapper, UserLabelRelEntity> implements UserLabelRelService {
    @Autowired
    private UserLabelRelMapper userLabelRelMapper;
    @Override
    public void deleteLabelByUserId(String userId) {
        LambdaQueryWrapper<UserLabelRelEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UserLabelRelEntity::getUserId, userId);
        baseMapper.delete(queryWrapper);

    }

    @Override
    public void batchInsert(List<UserLabelRelEntity> userLabelRelEntities) {
        userLabelRelMapper.insertBatchSomeColumn(userLabelRelEntities);
        /*userLabelRelMapper.(userLabelRelEntities);*/

    }

    @Override
    public List<UserLabelRelEntity> getLabelByUserId(String userId) {
        QueryWrapper<UserLabelRelEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public List<UserLabelRelEntity> getUserLabelRelByLabelId(String labelId){
        return baseMapper.selectList(new QueryWrapper<UserLabelRelEntity>().eq("label_id", labelId));
    }


}
